DELETE my_index

// index: 如果id不存在 这回创建新的文档
PUT my_index/_doc/1
{
    "user": "mike",
    "comment": "You know, for search"
}

// index: deleted -> x
GET _cat/indices/my_index

// index: 如果id存在, 会删除现有的文档, 再创建新的文档, 并且版本会增加
PUT my_index/_doc/1
{
    "user": "adg",
    "comment": "You know, for search"
}
// index: deleted -> x + 1
GET _cat/indices/my_index

// create: id不存在, 创建新的文档
PUT my_index/_create/2
{
    "user": "mike",
    "comment": "You know, for search"
}

// create: id已经存在, 会失败
PUT my_index/_create/2
{
    "user": "mike",
    "comment": "You know, for search"
}
// create: 不指定id, 自动生成
POST my_index/_doc
{
    "user": "mike",
    "comment": "You know, for search"
}

// read
GET my_index/_doc/1

// update: deleted -> x
GET _cat/indices/my_index

// update: 文档必须存在, 更新只会对相应字段做修改
POST my_index/_update/1
{
    "doc": {
        "user": "ccc1"
    }
}

// update:  deleted -> x + 1
GET _cat/indices/my_index


// delete

DELETE my_index/_doc/1

// es没有更新, 只有删了再加, 包括index和update操作, 
// 但是如果更新的值相同, 那么文档是不会改变的

// bulk API, 这个运行不了, 得复制到kibana dev tool里面运行
// 批量操作, 支持 index, create, update, delete四个操作
// 单条操作失败, 不影响其他操作, 返回结果包括每一条操作结果返回
POST _bulk
{"index": {"_index": "my_index", "_id": "1"}}
{"user": "abc", "comment": "You know, for search"}
{"create": {"_index": "my_index", "_id": "2"}}
{"user": "abcd", "comment": "You know, for search"}
{"update": {"_index": "my_index", "_id": "1"}}
{"doc":{"user": "abcde", "comment": "You know, for search"}}
{"delete": {"_index": "my_index", "_id": "4"}}

// 批量获取: 返回3条结果, 前两条相同, 最后一条未找到
GET _mget
{
    "docs": [
        {"_index": "my_index", "_id": "1"},
        {"_index": "my_index", "_id": "1"},
        {"_index": "my_index", "_id": "15"}
    ]
}

// 批量查询
GET _mget
{
    "docs": [
        {"_index": "my_index", "_id": "1"},
        {"_index": "my_index", "_id": "2"},
        {"_index": "my_index", "_id": "15"}
    ]
}

// 批量查询
GET my_index/_msearch

// Document APIs https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html